/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.osdtsystem.hierarchy;

import org.osdtsystem.utils.Storage;

/**
 *
 * @author Matthias Buch-Kromann
 */
public class WordHierarchy extends AbstractAffixHierarchy {
    public WordHierarchy(Storage dataStorage) {
        super(dataStorage);
    }

    @Override
    public AffixHClass intersectionBinary(AffixHClass hc1, AffixHClass hc2) {
        // Return empty class if either class is empty
        if (isEmpty(hc1) || isEmpty(hc2))
            return emptyClass();

        // Return the class if the two classes are identical
        if (hc1.equals(hc2))
            return hc1;
        
        // Return other class if one of the classes is the top class
        if (isTop(hc1))
            return hc2;
        if (isTop(hc2))
            return hc1;

        // Otherwise return the empty class
        return emptyClass();
    }

    @Override
    public AffixHClass superclass(String suffix, int depth) {
        // Return the word if depth is 1
        return depth == 0 ? topClass() : makeAffixClass(suffix, true);
    }
}
